export class lazyEvent {
  constructor() {

  }
  /* 函数节流 */
  static set(map){
    let DOM = map.dom
    let eventName = map.eventName
    let event = map.event
    let delay = map.delay ? map.delay : 100
    let timer = null
    let newEvent = function () {
      if(timer){
        return
      }else{
        event()
        timer = setTimeout(function () {
          clearTimeout(timer)
          timer = null
        },delay)
      }
    }
    DOM.addEventListener(eventName, newEvent)
  }
  // /* 事件节流 */ 弃用
  // static init(map){
  //   let DOM = map.dom
  //   let eventName = map.eventName
  //   let event = map.event
  //   let delay = map.delay ? map.delay : 100
  //   let newEvent = function () {
  //     event()
  //     DOM.removeEventListener(eventName,newEvent)
  //     setTimeout(function () {
  //       DOM.addEventListener(eventName,newEvent)
  //     },delay)
  //   }
  //   DOM.addEventListener(eventName, newEvent)
  // }
}
